<%--
  Created by IntelliJ IDEA.
  User: lan
  Date: 2015/10/5
  Time: 22:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
  <title>后台管理系统——出版社管理</title>
  <%@ include file="../../layout/import.jsp"%>
  <script type="text/javascript">
    function delPublisher(publisherId) {
      if(confirm("确定删除吗？删除后不可恢复！")){
        $.ajax({
          url: "/admin/delPublisher.do",
          data: {id:publisherId},
          method: "POST",
          dataType: "json",
          error: function () {
            alert("表单提交出错，请稍后再试");
          },
          success: function(response) {
            if(response.code == 0) {
              alert("删除成功");
              window.location.href = "/admin/publisher.do";
            }
            else {
              alert(response.description);
            }
          }
        });
      }
    }
  </script>
</head>
<body>
<%@ include file="nav.jsp"%>

<div class="container" style="min-height: 72%">
  <div class="col-sm-12">
    <a class="btn btn-primary" href="/admin/newPublisher.do">添加新出版社</a>
    <br /><br />
    <table class="table table-hover">
      <tr>
        <th>出版社名</th><th>联系人</th><th>联系人地址</th><th>E-mail</th><th>电话</th></th><th>网址</th><th>操作</th>
      </tr>

      <!--显示出版社信息-->
      <c:forEach var="publisher" items="${publisherList}">
        <tr>
          <td>${publisher.name}</td>
          <td>${publisher.linkman}</td>
          <td>${publisher.address}</td>
          <td>${publisher.email}</td>
          <td>${publisher.phone}</td>
          <td>${publisher.website}</td>
          <td>
            <a href="/admin/publisherEdit.do?id=${publisher.id}">编辑</a>
            <a onclick="delPublisher(${publisher.id})">删除</a>
          </td>
        </tr>
      </c:forEach>
    </table>


    <nav>
      <ul class="pagination">
        <!--
                <li <c:if test="${thisPage eq 1}">class="disabled"</c:if> >
                    <a href="/admin/book.do?page=${thisPage - 1}" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                -->
        <c:forEach var="page" begin="1" end="${totalPage}" step="1" >
          <li <c:if test="${thisPage eq page}">class="active"</c:if> ><a href="/admin/publisher.do?page=${page}" > ${page}</a></li>
        </c:forEach>
        <!--
                <li <c:if test="${thisPage eq totalPage}">class="disabled"</c:if>>
                    <a href="/admin/book.do?page=${thisPage + 1}" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
                -->
      </ul>
    </nav>
  </div>

</div>


<%@ include file="../footer.jsp"%>
</body>
</html>
